package com.example.no1admin.search.controller;

import com.example.no1admin.restful.JsonPage;
import com.example.no1admin.restful.JsonResult;
import com.example.no1admin.search.entity.RouteForES;
import com.example.no1admin.search.service.ISearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/search")
@Api(tags = "搜索模块")
public class SearchController {
    @Autowired
    private ISearchService searchService;

    @GetMapping
    @ApiOperation("根据用户输入关键字分页查询路线")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "搜索关键字",name = "keyword",dataType = "string"),
            @ApiImplicitParam(value = "页码",name = "page",dataType = "int"),
            @ApiImplicitParam(value = "每页条数",name = "pageSize",dataType = "int")
    })
    public JsonResult<JsonPage<RouteForES>> searchByKeyWord(String keyword, Integer page, Integer pageSize){
        JsonPage<RouteForES> list = searchService.search(keyword,page,pageSize);
        return JsonResult.ok(list);
    }
}
